# 拆分pdf文件

from PyPDF2 import PdfReader, PdfWriter

def chi_pdf(path):
    pdf = PdfReader(open(path, 'rb'))
    for i, page in enumerate(pdf.pages):
        writer = PdfWriter()
        writer.add_page(page)
        with open(f'../02.py_pdfFile/03.第{i + 1}页_pdf文件.pdf', 'wb') as out:
            writer.write(out)


if __name__ == '__main__':
    # 1. 将每一页拆分成一个pdf文件
    chi_pdf('../02.py_pdfFile/01.采购合同模板.pdf')
